<template>
	<view>
		<view class="news_item"  v-for="(item,key) in listData" :key="key" @click="goDetail(item)">
			<image :src="item.img"></image>
			<view class="right">
				<view class="tit">
					{{item.title}}
				</view>
				<view class="info">
					<text>{{item.time}}</text>
					<text>Author{item.author}}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				listData: []
			};
		},
		onLoad() {
			this.getData()
		},
		methods: {
			async getData(){
				const res=await this.$myRequest({
					url:'getInformation/getInformation'
				})
				this.listData=res.data;
				console.log(this.listData);
			},
			goDetail: function(e) {
				let detail = {
					author: e.author,
					img: e.img,
					id: e.id,
					time: e.time,
					title: e.title,
					content:e.content
				};
				uni.navigateTo({
					url: 'details?detailDate=' + encodeURIComponent(JSON.stringify(detail))
				});
			},
		}
	};
</script>

<style lang="scss">
	.news_item{
		display: flex;
		padding: 10rpx 20rpx;
		border-bottom: 1px solid grey;
		image{
			min-width: 200rpx;
			max-width: 200rpx;
			height: 150rpx;
		}
		.right{
			margin-left: 15rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			.tit{
				font-size: 30rpx;
			}
			.info{
				font-size: 24rpx;
				text:nth-child(2){
					margin-left: 30rpx;
				}
			}
		}
	}
</style>
